package com.ccn.crm.util;

import com.alibaba.fastjson.JSON;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GetDeptInfo {
    public static Map<String, Object> GetDeptInfoBycode(List<Object> deptId , String token) {
        int id = Integer.valueOf(deptId.get(0).toString());
//        System.out.println(id);
        String url = "https://open.fxiaoke.com/cgi/department/detail";
        Map<String, Object> jsonObject = new HashMap<String, Object>();
        //设置访问参数
        jsonObject.put("corpId","FSCID_A6D390D2E5FFF878491C1F5E6DA2994B");
        jsonObject.put("corpAccessToken",token);
        jsonObject.put("departmentId",id);
        //把参数转化为字符串
        String json = JSON.toJSONString(jsonObject);
        //调用工具进行跨域请求获取token的corpID等参数
        String post = HttpUtil.httpProxy(url, json, "post", "application/json");
        //  String str="{\"corpAccessToken\":\"7129AE8DA6F9C5188C40BA920118A0E2\",\"corpId\":\"FSCID_A6D390D2E5FFF878491C1F5E6DA2994B\",\"expiresIn\":2422,\"errorCode\":0,\"errorMessage\":\"success\"}\n";
        //将获取的参数转化成map类型
        HashMap deptInfo = JSON.parseObject(post, HashMap.class);
        return deptInfo;
    }
}
